import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Home from '@/views/HomeView.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'home',
    component: Home,
    redirect: '/myhome/recommend', // 默认跳转到推荐页面
    children: [
      {
        path: "myhome",
        component: () => import("../views/Home/home.vue"),
        // 三级路由配置
        children: [
          {
            path: "follow",
            component: () => import("@/components/follow.vue")
          },
          {
            path: "recommend",
            component: () => import("@/components/recommend.vue")
          },
          {
            path: "fatReduct",
            component: () => import("@/components/fatReduct.vue")
          },
          {
            path: "shop",
            component: () => import("@/components/shop.vue")
          },
          {
            path: "recipeType",
            component: () => import("@/components/recipeType.vue")
          }
        ]
      },
      {
        path: "course",
        component: () => import("../views/Course/course.vue")
      },
      {
        path: "post",
        component: () => import("../views/Post/post.vue")
      },
      {
        path: "favorite",
        component: () => import("../views/Favorite/favorite.vue")
      },
      {
        path: "profile",
        component: () => import("../views/Profile/profile.vue")
      }
    ]
  },
  {
    path: "/recipeTypeInfo",
    name: "recipeTypeInfo",
    component: () => import("../components/recipeTypeInfo.vue"),
  },
  {
    path: "/recipe-detail",
    component: ()=> import("../components/recipeDetails.vue")
  },
  {
    path: "/follow-detail",
    component: ()=> import("../components/followDetails.vue")
  },

  {
    path: "/searchResult",
    component: () => import("../components/searchResult.vue"),
  },
  {
    path: "/login",
    component: () => import("../views/Login.vue")
  },
  {
    path: "/reg",
    component: () => import("../views/Reg.vue")
  },
  {
    path: "/recipeDetails",
    component: () => import("../components/recipeDetails.vue")
  },
  {
    path: "/cmenu",
    component: () => import("../views/Home/customMenu.vue")
  },
  {
    path: "/addWorks",
    component: () => import("../views/Post/addWorks.vue")
  },
  {
    path: "/addRecipe",
    component: () => import("../views/Post/addRecipe.vue")
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
